<template>
	<view class="box">
		<view>
			<drawer :show="isDrawerOpen" @close="closeDrawer"></drawer>
		</view>
		<view>
			<languageMask :show="isOpenMask" @close="closeMask" @languageChanged="refreshLanguage"></languageMask>
		</view>
		<view class="head">
			<view style="display: flex;align-items: center;">
				<image src="../../static/qukuailian2_slices/danlieliebiao.png" class="list" @click="openDrawer"></image>
				<image src="../../static/caifubeifen_slices/lujing9.png" mode="" class="back" @click="toDetails">
				</image>
			</view>
			<view class="head-title">
				<view class="vtitle">{{$data.$language.Password}}</view>
			</view>
			<view class="right-head">
				<image src="../../static/qianbaobeifen2_slices/diqiugenghuan.png" mode="" class="language" @click="openMask">
				</image>
			</view>
		</view>
		<view class="mon-certer">
			<view class="monblin">
				<view class="inmuview">
					{{$data.$language.PasswordLInde}}：
				</view>
				<view class="">
					<input type="password" :placeholder="$data.$language.Passwordinput" v-model="password" :maxlength='6'>
				</view>
			</view>
			<view class="monblin">
				<view class="inmuview">
					{{$data.$language.PasswordLInde1}}：
				</view>
				<view class="">
					<input type="password" :placeholder="$data.$language.Passwordinput1" v-model="password1" :maxlength='6'>
				</view>
			</view>
			<view class="viewBnt" @click="litspawodeBtn()">
				{{$data.$language.qbtn}}
			</view>
			<view class="ninmians" @click="btnclisinBtn">
				<!-- 忘记密码，请联系客服。 -->
				{{$data.$language.customerservice}}
			</view>
		</view>
		
		<view style="width: 100%;height: 50rpx;">
			
		</view>
	</view>
</template>

<script>
	import drawer from "../../my-components/drawer/drawer.vue"
	import languageMask from "../../my-components/languageMask/languageMask.vue"
	import zhCN from '@/locales/zh-CN.js'
	import enUS from '@/locales/en-US.js'
	import trCN from '@/locales/tr-CN.js'
	import {
		passwordTwo,
		passwordOne
	} from '@/api/index.js';
	export default {
		data() {
			return {
				// $language: uni.getStorageSync('locale') == 'en-US' ? enUS : zhCN,
				isDrawerOpen: false,
				isOpenMask: false,
				moxData:{},
				password:'',
				password1:''

			}
		},
		onReachBottom() {  
		},
		onLoad() {
			var translate = uni.getStorageSync('locale')
			if(translate=='en-US'){
				this.$data.$language = enUS
			}else if(translate=='zh-CN'){
				this.$data.$language = zhCN
			}else{
				this.$data.$language = trCN
			}
			this.listData()
		},
		methods: {
			btnclisinBtn(){
				window.location.href= 'https://t.me/+85253093521'
			},
			litspawodeBtn(){
				var mimabuyizhi = this.$data.$language.mimabuyizhi
				var yijingzshezhi = this.$data.$language.yijingzshezhi
				var shehzichengg = this.$data.$language.shehzichengg
				if(this.password != this.password1){
					uni.showToast({
						title:mimabuyizhi,
						icon:'none',
						duration:2000
					})
				}else if(this.moxData.is_pass!=0){
					uni.showToast({
						title:yijingzshezhi,
						icon:'none',
						duration:2000
					})
				}else{
					passwordTwo({
								password:this.password,
							},
						(data) => {
							// 处理成功返回的数据
							uni.showToast({
								title:shehzichengg,
								icon:'none',
								duration:2000
							})
							this.listData()
						},
						(errorMsg) => {
							// 处理请求失败或错误的情况
							console.error(errorMsg);
						},
					);
				}
				
			},
			listData(){
				passwordOne((data) => {
						// 处理成功返回的数据
						console.log(data, 'dat我的意识到')
						this.moxData = data
					},
					(errorMsg) => {
						// 处理请求失败或错误的情况
						console.error(errorMsg);
					}
				)
			},
			refreshLanguage(locale) {
				if (locale === 'zh-CN') {
					this.$language = zhCN
				} else if (locale === 'en-US') {
					this.$language = enUS
				}else{
					  this.$language = trCN
				  }
				uni.reLaunch({
					url: '/pages/buyNodes/Password'
				});

			},
			toDetails() {
				uni.navigateTo({
					url: '/pages/details/details'
				})
			},
			openDrawer() {
				this.isDrawerOpen = true
			},
			closeDrawer() {
				this.isDrawerOpen = false
			},
			openMask() {
				this.isOpenMask = true
			},
			closeMask() {
				this.isOpenMask = false; // 遮罩层guanbi事件处理
			},
		},

		components: {
			drawer,
			languageMask
		}
	}
</script>

<style lang="less">
	page{
		background-color: #fff !important;
	}
	uni-page-body{
		background-color: #fff !important;
	}
	.box {
		width: 750rpx;
		background: #FFFFFF;
	}

	.head {
		padding: 40rpx;
	}

	.headline {
		display: flex;
	}

	.title {
		width: 164rpx;
		height: 48rpx;
		font-size: 34rpx;
		font-family: PingFangSC-Semibold, PingFang SC;
		font-weight: 600;
		color: #000000;
		line-height: 48rpx;
		margin: 28.85rpx 0 0 158rpx;
	}
	.mon-certer{
		width: 100%;
		padding:  40rpx ;
		box-sizing: border-box;
		.monblin{
			width: 100%;
			// height: 80rpx;
			display: flex;
			margin-top: 24rpx;
			.inmuview{
				width: 190rpx;
				text-align-last: justify;
			}
			view{
				
				line-height: 80rpx;
			}
			input{
				width: 500rpx;
				height: 80rpx;
				border: 1rpx solid #e9e9e9;
				padding: 0 24rpx;
				box-sizing: border-box;
				border-radius: 14rpx;
			}
			
		}
		.viewBnt{
			width: 100%;
			height: 80rpx;
			background-color: #0762FF;
			border-radius: 14rpx;
			line-height: 80rpx;
			text-align: center;
			color: #FFFFFF;
			margin-top: 30rpx;
		}
		.ninmians{
			width: 100%;
			text-align: center;
			margin-top: 60rpx;
			// text-decoration:underline;
		}
	}
	

</style>